<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Ccu {
    private $secret_key = 'tzr-2012.11.11-kvajzcmtnpwxdsrl';

    function __construct() {
    }
    
    public function get_ccu($dns) {    	
        $time = time();		
		$key = $this->secret_key;
		$sign = md5($time.$key);
		$uri = 'http://' . $dns . '/api/yuenan/get_online_count.php?time=' . $time . '&sign=' . $sign;

		$content = @file_get_contents($uri);

		return json_decode($content);
    }    
    
    public function top_family($dns) {
    	$time = time();
    	$key = $this->secret_key;
    	$sign = md5($time.$key);
    	$uri = 'http://' . $dns . '/api/yuenan/get_top_member_family.php?time=' . $time . '&sign=' . $sign;
    	$content = @file_get_contents($uri);    	    	
    	return json_decode($content);
    }
    
    public function account_details($dns, $account){
    	$time = time();
    	$key = $this->secret_key;
    	$sign = md5($account.$time.$key);
    	$uri = 'http://' . $dns . '/api/yuenan/account_detail.php?time=' .  $time  . '&account=' . $account . '&sign=' . $sign;
    	$content = @file_get_contents($uri);
    	return json_decode($content);
    }
}